/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2023. All rights reserved.
 * Description: UDK args header file
 * Author: -
 * Create: 2021.5.6
 */

#ifndef UDK_ARGS_H
#define UDK_ARGS_H

#include <stdint.h>

#define UDK_KVARGS_MAX 32
#define UDK_KVARGS_PAIRS_DELIM ","
#define UDK_KVARGS_KV_DELIM "="

/* Type of callback function used by udk_kvargs_process() */
typedef int (*arg_handler_t)(const char *key, const char *value, void *opaque);

struct udk_kvargs_pair {
    char *key;
    char *value;
};

struct udk_kvargs {
    char *str;
    uint32_t count;
    struct udk_kvargs_pair pairs[UDK_KVARGS_MAX];
};

struct udk_kvargs *udk_kvargs_parse(const char *args, const char * const valid_keys[]);
int udk_kvargs_process(const struct udk_kvargs *kvlist, const char *key_match, arg_handler_t handler, void *opaque_arg);
uint32_t udk_kvargs_count(const struct udk_kvargs *kvlist, const char *key_match);
void udk_kvargs_free(struct udk_kvargs *kvlist);

#endif /* UDK_ARGS_H */